import requests
import config

class EmployeeAPI:
    def __init__(self):
        self.url_add_employee = config.BASE_URL + "/api/sys/user"
        self.url_update_employee = config.BASE_URL + "/api/sys/user/{}"
        self.url_get_employee = config.BASE_URL + "/api/sys/user/{}"
        self.url_delete_employee = config.BASE_URL + "/api/sys/user/{}"

    #请求添加员工接口
    def add_emplayee(self,add_employee_data):
        return requests.post(url=self.url_add_employee,json=add_employee_data,headers=config.headers_data)

    #请求修改员工接口
    def update_emplayee(self,updata_employee_data,employee_id):
        format_data=self.url_update_employee.format(employee_id)
        return requests.put(url=format_data,json=updata_employee_data,headers=config.headers_data)

    #请求查询接口
    def get_employee(self,employee_id):
        format_data=self.url_get_employee.format(employee_id)
        print(format_data)
        return requests.get(url=format_data,headers=config.headers_data)

    #请求删除接口
    def delete_employee(self,employee_id):
        format_data=self.url_delete_employee.format(employee_id)
        return requests.delete(url=format_data,headers=config.headers_data)